package com.hydra.startup.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hydra.startup.beans.Book;
import com.hydra.startup.daos.BookDao;

@Service
public class BookServiceImpl implements BookService {
	
	@Autowired
	private BookDao bookDao;
	
	@Transactional
	public void addBook(Book book) {
		bookDao.save(book);
	}
	
	@Transactional
	public void updateBook(Book book) {
		bookDao.update(book);
	}
	
	@Transactional
	public Book getBookById(Integer bookId) {
		return bookDao.get(bookId);
	}
	
	@Transactional
	public List<Book> listBooks() {
		return bookDao.loadAll();
	}
	
	@Transactional
	public void deleteBook(Book book) {
		bookDao.delete(book);
	}
	
}
